/* =============================================
Comment: 새창을 연다
Return :
Usage  :
============================================= */
function openWindow(url, winName, winWidth, winHeight, winOptions) {
	var posX=0;
	var posY=0;
	var nWidth=Number(winWidth);
	var nHeight=Number(winHeight);

	if (screen.width>nWidth) {
		posX=(screen.width-nWidth)/2;
	} else {
		nWidth=screen.width;
	}

	if (screen.height>nHeight) {
		posY=(screen.height-nHeight)/2;
	} else {
		nHeight=screen.height;
	}

	winProps="width="+nWidth+", height="+nHeight+", top="+posY+", left="+posX+", "+winOptions;

	winP = window.open(url,winName,winProps);

	//return winP;
}


/* =============================================
Comment: 윈도의 크기를 변화시킨다.
		입력 사이즈가 음수이면 현재 윈도사이즈,
		true 이면 창을 가운데로 위치시킨다.
Return :
Usage  : resizeWindow(-1, 500, true);
============================================= */
function resizeWindow(nWidth, nHeight, isCenter) {
	if (nWidth > 0) {
		if (nWidth > screen.width) {
			nWidth = screen.width;
		}
	} else {
		nWidth = document.body.clientWidth;
	}

	if (nHeight > 0) {
		if (nHeight > screen.height) {
			nHeight = screen.height;
		}
	} else {
		nHeight = document.body.clientHeight;
	}

	var posX=0;
	var posY=0;
	if (isCenter) {
		posX = (screen.width - nWidth) / 2;
		posY = (screen.height - nHeight) / 2;

		window.moveTo(posX, posY);
	}

	window.resizeBy(nWidth - document.body.clientWidth, nHeight - document.body.clientHeight);

	if (isCenter) { //창크기때문에 이동이 덜 되었을때 대비 재이동
		window.moveTo(posX, posY);
	}
}

/* =============================================
Comment: 검증결과 처리용 윈도우를 팝업한다.
Return :
Usage  : resizeWindow(-1, 500, true);
============================================= */
function openInspectContentWindow(contentId) {
	ationUrl = "/bppoc/workflow/workflow/inspectContent.omp?contentId=" + contentId;
	openWindow(ationUrl, "INSPECT_WINDOW", 720, 440, "resizable=yes,menubar=0,scrollbars=yes");
}

/* =============================================
Comment: 콘텐츠 상세 정보 팝업.
Return :
Usage  : resizeWindow(-1, 500, true);
============================================= */
function openEpisodeViewWindow(contentId) {
	ationUrl = "/bppoc/episode/c_contentViewAction.omp?contentId=" + contentId+ "&isIframe=n&readonly=YES&ispopup=YES&listurl=";
	openWindow(ationUrl, "EPISODE_WINDOW", 720, 740, "resizable=yes,menubar=0,scrollbars=yes");
}

/* =============================================
Comment: 고화질 콘텐츠 상세 정보 팝업. - 이북,코믹,잡지 등 구MM 아닌 것 모두
Return :
Usage  : resizeWindow(-1, 500, true);
============================================= */
function openHdEpisodeViewWindow(contentId, contentType) {
	var ationUrl = "/bppoc/hd/viewDetail.omp?contentId=" + contentId+ "&isIframe=n&readonly=YES&ispopup=YES&listurl=";

	// 이북
	if(contentType == '16') {
		ationUrl = "/bppoc/ebook/viewDetail.omp?contentId=" + contentId+ "&isIframe=n&readonly=YES&ispopup=YES&listurl=";
	}
	// 코믹
	else if(contentType == '13' || contentType == '14') {
		ationUrl = "/bppoc/comic/viewDetail.omp?contentId=" + contentId+ "&isIframe=n&readonly=YES&ispopup=YES&listurl=";
	}
	// 잡지
	else if(contentType == '19' || contentType == '20') {
		ationUrl = "/bppoc/mgz/viewDetail.omp?contentId=" + contentId+ "&isIframe=n&readonly=YES&ispopup=YES&listurl=";
	}
	// 그 외는 VOD
	else {
		ationUrl = "/bppoc/hd/viewDetail.omp?contentId=" + contentId+ "&isIframe=n&readonly=YES&ispopup=YES&listurl=";
	}

	openWindow(ationUrl, "EPISODE_WINDOW", 720, 740, "resizable=yes,menubar=0,scrollbars=yes");
}

/* =============================================
Comment: 이북 콘텐츠 상세 정보 팝업.
Return :
Usage  : resizeWindow(-1, 500, true);
============================================= */
function openEbookEpisodeViewWindow(contentId) {
	ationUrl = "/bppoc/ebook/viewDetail.omp?contentId=" + contentId+ "&isIframe=n&readonly=YES&ispopup=YES&listurl=";
	openWindow(ationUrl, "EPISODE_WINDOW", 720, 740, "resizable=yes,menubar=0,scrollbars=yes");
}

/* =============================================
Comment: 이북 콘텐츠 상세 정보 팝업.
Return :
Usage  : resizeWindow(-1, 500, true);
============================================= */
function openComicEpisodeViewWindow(contentId) {
	ationUrl = "/bppoc/comic/viewDetail.omp?contentId=" + contentId+ "&isIframe=n&readonly=YES&ispopup=YES&listurl=";
	openWindow(ationUrl, "EPISODE_WINDOW", 720, 740, "resizable=yes,menubar=0,scrollbars=yes");
}

/* =============================================
Comment: 잡지 콘텐츠 상세 정보 팝업.
Return :
Usage  : resizeWindow(-1, 500, true);
============================================= */
function openMgzEpisodeViewWindow(contentId) {
	ationUrl = "/bppoc/mgz/viewDetail.omp?contentId=" + contentId+ "&isIframe=n&readonly=YES&ispopup=YES&listurl=";
	openWindow(ationUrl, "EPISODE_WINDOW", 720, 740, "resizable=yes,menubar=0,scrollbars=yes");
}
